package com.baidu.controller;

import com.baidu.service.impl.UserControllerServiceImpl;
import com.until.response.RestfulCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @author user
 */
@RestController
@RequestMapping("user")
public class UserController{

    @Autowired
    private UserControllerServiceImpl userControllerService;

    @PostMapping(value = "user-login.action",produces = "application/json;charset=UTF-8")
    public RestfulCode.CodeSatCode userLoginAction(@RequestBody Map<String,Object> request,HttpServletResponse response){
        String username = String.valueOf(request.get("username"));
        String password = String.valueOf(request.get("password"));
        return userControllerService.userLogin(username, password, response);
    }

    @GetMapping("{id}")
    public RestfulCode.CodeSatCode getUserInfoAction(@PathVariable Integer id){
        return userControllerService.getUserInfo(id);
    }

}
